<template>
  <div class="flTrain-list">
    <el-dialog 
      class="flTrain-head"
      v-el-drag-dialog="{drag: true, full: true, resize: true}"
      title="信息查询" 
      :close-on-click-modal="false"
      :visible.sync="md.state"
      @close="closeMd"
      v-if="md.state"
      width = '30%'
    >

    <div class="headerTab" style="width:50%">
        <ul>
            <li v-for="(it,index) in placeArr" 
            :key="it.selectType"
            v-bind:class="{seatClassClick:index == activeItem}" 
            @click="actionIndexSelect(index,it)"
            >
                {{it.selectType}}
            </li>
        </ul>
    </div>

    <!-- 地点录入 -->
    <el-form :model="fm.ps" :ref="fm.fname" :label-width="'100px'"  @keyup.enter.native="onSubmit" v-if="fm.xs.isShow == true">
        <el-form-item 
          prop="startDetail"
          :rules="[
            { required: true, message: '请输入地址', trigger: 'blur' },
          ]"
          label="地址"
        >
            <el-col :span="17">
                <el-input 
                    v-model="fm.ps.startDetail"
                    type="search"
                    id="search"
                    placeholder="请输入地址"
                ></el-input>
                <div class="tip-box" id="searchTip"></div>

                <el-amap class="amap-box"
                    :amap-manager="amapManager"
                    :vid="'amap-vue'"
                    :zoom="zoom"
                    :plugin="plugin"
                    :center="center"
                    :events="events"
                >
                </el-amap>
                
            </el-col>
            
          
        </el-form-item>


        <el-form-item 
          prop="stime"
          :rules="[
            { required: true, message: '请输入时间', trigger: 'blur' },
          ]"
          label="开始时间"
        >
            <el-col :span="17">
                <el-date-picker
                    v-model="fm.ps.stime"
                    placeholder="请选择您的车次出发时间"
                    type="datetime"
                    value-format="yyyy-MM-dd HH:mm"
                    >
                </el-date-picker>
            </el-col>
          
        </el-form-item>
        <div class="trainFind" style="width:auto; border:none"></div>

        <el-form-item class="flTr-btn">
          <el-button type="primary" :disabled="fm.sb.load" @click="addressBtn">{{fm.sb.text}}</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
    </el-form>


    <!-- 车次录入 -->
    <el-form  :model="fmTrain.ps" :ref="fmTrain.fname" :label-width="'100px'"  @keyup.enter.native="onSubmit" v-if="fmTrain.xs.isShow == true">
        <div class="haveTrain" v-if="fmTrain.xs.isTrain">
            <el-form-item 
                prop="trainNo"
                :rules="[
                    { required: true, message: '请输入需要查询的火车车次号', trigger: 'blur' },
                ]"
                label="火车车次号"
                >
                <el-col :span="14">
                    <el-input 
                        v-model="fmTrain.ps.trainNo" 
                        placeholder="请输入需要查询的火车车次号"
                    ></el-input>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button @click="isTrainbtn('no')">无车次号</el-button>
                </el-col>
                
            </el-form-item>

            <el-form-item 
                prop="stime"
                :rules="[
                    { required: true, message: '请选择您的车次出发时间', trigger: 'blur' },
                ]"
                label="出发时间"
                >
                <el-col :span="14">
                    <el-date-picker
                        v-model="fmTrain.ps.stime" 
                        placeholder="请选择您的车次出发时间"
                        type="date"
                        value-format="yyyy-MM-dd"
                        >
                    </el-date-picker>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button type="primary" style="width:80px" :disabled="fmTrain.sb.load" @click="findTrain">查询</el-button>
                </el-col>
            </el-form-item>


            <div class="findTitle">
                <span>提示：到达车站时间需提前1小时</span>
            </div>

            <!-- <div class="trainFind"></div> -->
            <div class="flight-textarea-box">
                <!-- <div class="train-textarea" ng-if="!trainMsgShow">没有数据！</div> -->
                <div class="train-textarea" v-for="(v,index) in fmTrain.trainResult" :key="index">
                    <div class="train-textarea-header">
                        <div>{{v.typename}}{{v.trainno}}</div>
                        <div><span>{{fmTrain.lookTrainText.daTime}}</span>到站</div>
                        <div><span>{{fmTrain.lookTrainText.dateJ}}</span></div>
                    </div>
                    <div class="train-zd"><span>接站点：</span><span>{{fmTrain.lookTrainText.stationWrite}}</span></div>
                    <div class="find-train-list">
                        <span>{{v.typename}}{{v.trainno}}&nbsp;{{v.startstation}}<i class="el-icon-right"></i>&nbsp;{{v.endstation}}</span>
                        <span ng-click="clickTrain(trainLookIcon)" class="train-btn">全部站点&nbsp;&nbsp;<i class="el-icon-bottom"></i></span>
                    </div>
                    <ul class="train-list" ng-show="lookStation">
                        <li>
                            <P style="width: 50px;">编号</P>
                            <P style="width: 75px;">站名</P>
                            <P style="width: 75px;">进站</P>
                            <P>发车</P>
                            <P>停留</P>
                        </li>
                        <li v-for="(w,index) in v.list" :key="index">
                            <p style="width: 50px;">{{w.sequenceno}}</p>
                            <p style="width: 75px;">{{w.station || "--"}}</p>
                            <p style="width: 75px;">{{w.arrivaltime || "--"}}</p>
                            <p>{{w.departuretime}}</p>
                            <p>{{w.stoptime || "--"}}分钟</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        


        <div class="noTrain" v-if="!fmTrain.xs.isTrain">
            <el-form-item 
                prop="stime"
                :rules="[
                    { required: true, message: '请选择您的出发时间', trigger: 'blur' },
                ]"
                label="出发时间"
                >
                <el-col :span="14">
                    <el-date-picker
                        v-model="fmTrain.ps.stime" 
                        placeholder="请选择您的车次出发时间"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                    </el-date-picker>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button type="primary" style="width:80px" @click="isTrainbtn('have')">有车次号</el-button>
                </el-col>
            </el-form-item>
            <div class="findTitle">
                <span>提示：到达车站时间需提前1小时</span>
            </div>
            <div class="noTrainzd">
                <ul>
                    <li v-for="(i,index) in newStationList" :key="index" @click="checkStation(index,i)" v-bind:class="{flightClassClick:index == fmTrain.ps.activeSelectTrain}">
                        <span class="el-icon-location-outline marker-icon">&nbsp;&nbsp;</span>
                        <span class="station-word">{{i.name}}</span>
                    </li>
                </ul>
            </div>
        </div>

        <el-form-item class="flTr-btn">
          <el-button type="primary" :disabled="fmTrain.sb.load" @click="trainBtn">{{fmTrain.sb.text}}</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
    </el-form>


    <!-- 航班录入 -->
    <el-form  :model="fmFlight.ps" :ref="fmFlight.fname" :label-width="'100px'"  @keyup.enter.native="onSubmit" v-if="fmFlight.xs.isShow == true">
        <div class="haveTrain" v-if="fmFlight.xs.isFlight">
            <el-form-item 
                prop="flightNo"
                :rules="[
                    { required: true, message: '请输入需要查询的航班号', trigger: 'blur' },
                ]"
                label="航班号"
                >
                <el-col :span="14">
                    <el-input 
                        v-model="fmFlight.ps.flightNo" 
                        placeholder="请输入需要查询的航班号"
                    ></el-input>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button @click="isFlightbtn('no')">无航班号</el-button>
                </el-col>
                
            </el-form-item>

            <el-form-item 
                prop="stime"
                :rules="[
                    { required: true, message: '请选择您的航班出发时间', trigger: 'blur' },
                ]"
                label="出发时间"
                >
                <el-col :span="14">
                    <el-date-picker
                        v-model="fmFlight.ps.stime" 
                        placeholder="请选择您的航班出发时间"
                        type="date"
                        value-format="yyyy-MM-dd"
                        >
                    </el-date-picker>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button type="primary" style="width:80px" @click="findFlight">查询</el-button>
                </el-col>
            </el-form-item>


            <div class="findTitle">
                <span>提示：到达机场时间需提前1小时</span>
            </div>
            <div class="flight-textarea-box">
                <!-- <div class="flight-textarea" ng-if="!flightMsgShow">没有数据！</div> -->
                <div class="flight-textarea">
                    <ul>
                        <li v-for="(f,index) in fmFlight.flightResult" :key="index" @click="activeIndex(index,f)" v-bind:class="{flightClassClick:index == fmFlight.ps.activeSelectFlight}">
                            <p>航班号：{{f.flightNo}}</p>
                            <p>起止机场：{{f.depPort}}{{f.depTerminal}}-{{f.arrPort}}{{f.arrTerminal}}</p>
                            <p>起止时间：{{f.depScheduled}}-{{f.arrScheduled}}</p>
                        </li>
                    </ul>
                </div>
            </div>
        </div>

        <div class="noFlight" v-if="!fmFlight.xs.isFlight">
            <el-form-item 
                prop="stime"
                :rules="[
                    { required: true, message: '请选择您的航班出发时间', trigger: 'blur' },
                ]"
                label="出发时间"
                >
                <el-col :span="14">
                    <el-date-picker
                        v-model="fmFlight.ps.stime" 
                        placeholder="请选择您的航班出发时间"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        >
                    </el-date-picker>
                </el-col>

                <el-col :span="2" :offset="1">
                    <el-button type="primary" style="width:80px" @click="isFlightbtn('have')">有航班号</el-button>
                </el-col>
            </el-form-item>
            <div class="findTitle">
                <span>提示：到达机场时间需提前1小时</span>
            </div>
            <div class="noTrainzd">
                <ul>
                    <li v-for="(i,index) in newStationList" :key="index" @click="checkStationFlight(index,i)" v-bind:class="{flightClass:index == fmFlight.ps.activeSelectFlight}">
                        <span class="el-icon-location-outline marker-icon">&nbsp;&nbsp;</span>
                        <span class="station-word">{{i.name}}</span>
                    </li>
                </ul>
            </div>
        </div>

        <el-form-item class="flTr-btn">
          <el-button type="primary" :disabled="fmFlight.sb.load" @click="saveFlightData">{{fmFlight.sb.text}}</el-button>
          <el-button @click="resetForm">重置</el-button>
        </el-form-item>
    </el-form>


        

      
    </el-dialog>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import elDragDialog from '@/directive/el-drag-dialog';
import UploadImg from '@/components/UploadImg';
import * as commonService from '@/api/services/common.service';
// NPM 方式
import {AMapManager, lazyAMapApiLoaderInstance} from 'vue-amap';

let amapManager = new AMapManager()

export default {
  name: 'FlTrainFind',
  directives: { elDragDialog },
  props: [ 'state', 'data'  ],
  components: { UploadImg },
  computed: {
    ...mapGetters([ 'lunitNum', 'uname' ])
  },
  data() {
      const that = this;
    return {

        address: null,
        searchKey: '',
        amapManager,
        markers: [],
        searchOption: {
            city: '全国',
            citylimit: true
        },
        center: [121.329402, 31.228667],
        zoom: 17,
        lng: 0,
        lat: 0,
        loaded: false,
        markerEvent:{
            click(e){
            }
        },
        events: {
            init() {
                lazyAMapApiLoaderInstance.load().then(() => {
                    that.initSearch()
                })
            },
            // 点击获取地址的数据
            // lng精度
            // lat维度
            click(e) {
                that.markers = []
                let {lng, lat} = e.lnglat
                that.lng = lng
                that.lat = lat
                that.center = [lng, lat]
                that.markers.push([lng, lat])
                // 这里通过高德 SDK 完成。
                let geocoder = new AMap.Geocoder({
                    radius: 1000,
                    extensions: 'all'
                })
                geocoder.getAddress([lng, lat], function (status, result) {
                    if (status === 'complete' && result.info === 'OK') {
                        if (result && result.regeocode) {
                            that.address = result.regeocode.formattedAddress
                            that.fm.ps.address = result.regeocode.formattedAddress
                            that.$nextTick()
                        }
                    }
                })
            }
        },
        // 一些工具插件
        plugin: [
            {
                // 定位
                pName: 'Geolocation',
                events: {
                    init(o) {
                        // o是高德地图定位插件实例
                        o.getCurrentPosition((status, result) => {
                            if (result && result.position) {
                                // 设置经度
                                that.lng = result.position.lng
                                // 设置维度
                                that.lat = result.position.lat
                                // 设置坐标
                                that.center = [that.lng, that.lat]
                                that.markers.push([that.lng, that.lat])
                                // load
                                that.loaded = true
                                // 页面渲染好后
                                that.$nextTick()
                            }
                        })
                    },
                    click(e){
                    }
                }
            },
            {
                // 搜索
                pName: 'PlaceSearch',
                events: {
                    init(instance) {
                    }
                }
            }
        ],



        md: { state: this.state },

        //   地点录入数组
        fm: {
            fname: 'dzFm',
            sb: { load: false, text: '保存' },
            ps: {
                sname: "",
                stime: "",
                startDetail: "",
                address: "",
            },

            xs: {isShow: true},
        },

        //   车次录入数组
        fmTrain: {
            fname: 'dzFm',
            sb: { load: false, text: '保存' },
            ps: {
                trainNo: "",
                startDetail: "",
                address: "",
                pdisBtn:true, //判断是否停靠点是当前城市
                backStartAddressSec:"", //判断有无车次号
                activeSelectTrain:"未选中",
                stime:"",
                trainNumLook:"" //用于详情展示时
            },

            lookTrainText:{
                stationWrite:'', //接站点
                daTime:'',//到站时间
                dateJ:'',
            },

            xs: {isShow: false,isTrain:true},
            trainResult: [] //火车查询结果
        },

        //   航班录入数组
        fmFlight: {
            fname: 'dzFm',
            sb: { load: false, text: '保存' },
            ps: {
                flightNo: "",
                startDetail: "",
                address: "",
                pdisBtn:true, //判断是否停靠点是当前城市
                backStartAddressSec:"", //判断有无航班号
                activeSelectFlight:"未选中",
                stime:"",
                flightNumLook:"", //用于详情展示时
                flightResultSelect:"" //用于选择航班
            },

            xs: {isShow: false,isFlight:true},
            flightResult:[] //航班查询结果
        },

        placeArr: [
            {
                selectType:"地点录入",
                id:"0",
            },
            {
                selectType:"车次",
                id:"1",
                isShuttle:"2"
            },
            {
                selectType:"航班",
                id:"2",
                isShuttle:"0"
            }
        ],
        activeItem:0,
        newStationList: [], //获取车次站点
        
     
    }
    
  },
  created() {
    const that = this;
    let list = that.data;



  },
  methods:{
     /* 
     *获取-火车站点
     */
    getStationListNew(v){
        const that = this;

        let loading = that.U.qloading('数据请求中...');
        commonService.getStationList({travelWay:v,city:'成都市'}).then(res=> {
            that.newStationList = res.data;

            that.U.qclose(loading);
        })

    },

    /* 关闭弹框 */
    closeMd(){
      this.$emit('getMdState', false);
    },
    /**
     * 切换Tab
     */

    actionIndexSelect(index,v){
        const that = this;

        that.activeItem = index;
        if(v.selectType == "地点录入"){
            that.fm.xs.isShow = true;
            that.fmTrain.xs.isShow = false;
            that.fmFlight.xs.isShow = false;
        }else if(v.selectType == "车次"){
            that.fm.xs.isShow = false;
            that.fmTrain.xs.isShow = true;
            that.fmFlight.xs.isShow = false;
            that.getStationListNew('2');
        }else if(v.selectType == "航班"){
            that.fm.xs.isShow = false;
            that.fmTrain.xs.isShow = false;
            that.fmFlight.xs.isShow = true;
            that.getStationListNew('1');
        }
    },
    resetForm() { // 重置表单
      this.$refs[this.fm.fname].resetFields();
    },

    // 有/无车次号
    isTrainbtn(v){
        const that = this;

        that.fmTrain.ps.stime = "";
        that.fmTrain.ps.backStartAddressSec = "";
        that.fmTrain.ps.trainNo = "";
        that.fmTrain.ps.activeSelectFlight = "未选中";
        that.fmTrain.ps.trainNumLook = "";
        that.fmTrain.trainResult = [];
        if(v == "no"){
            that.fmTrain.xs.isTrain = false;
        }else{
            that.fmTrain.xs.isTrain = true;
        } 
    },
    // 有/无航班号
    isFlightbtn(v){
        const that = this;

        that.fmFlight.ps.stime = "";
        that.fmFlight.ps.backStartAddressSec = "";
        that.fmFlight.ps.flightNo = "";
        that.fmFlight.ps.activeSelectFlight = "未选中";
        that.fmFlight.ps.flightNumLook = "";
        that.fmFlight.ps.flightResultSelect = "";
        that.fmFlight.flightResult = [];
        if(v == "no"){
            that.fmFlight.xs.isFlight = false;
        }else{
            that.fmFlight.xs.isFlight = true;
        } 
    },

    submitAddress(){
    },
    initSearch() {
        let vm = this
        let map = this.amapManager.getMap()
        AMapUI.loadUI(['misc/PoiPicker'], function (PoiPicker) {
            var poiPicker = new PoiPicker({
                input: 'search',
                placeSearchOptions: {
                    map: map,
                    pageSize: 10
                },
                suggestContainer: 'searchTip',
                searchResultsContainer: 'searchTip'
            })
            vm.poiPicker = poiPicker
            // 监听poi选中信息
            poiPicker.on('poiPicked', function (poiResult) {
                let source = poiResult.source
                let poi = poiResult.item
                if (source !== 'search') {
                    poiPicker.searchByKeyword(poi.name)
                } else {
                    poiPicker.clearSearchResults()
                    vm.markers = []
                    let lng = poi.location.lng;
                    let lat = poi.location.lat;
                    let address = poi.cityname + poi.adname + poi.name;
                    let LatLng = poi.location.lng+','+poi.location.lat;
                    let areaAll = poi.pname+'-'+ poi.cityname+'-'+poi.adname;
                    let addressDetail = poi.name;


                     let info = {
                        addressDetail:addressDetail,
                        LatLng:LatLng,
                        areaAll:areaAll,
                    }
                    vm.markers.push([lng, lat]);

                    vm.fm.ps.address = info;
                    vm.fm.ps.startDetail = addressDetail;
                }
            })
        })
    },
    searchByHand() {
        if (this.fm.ps.address !== '') {
            this.poiPicker.searchByKeyword(this.fm.ps.address);
        }
    },



    // 地点录入
    addressBtn(){
        const that = this;

        that.$refs[that.fm.fname].validate((valid) => {
            if (!valid) {
                that.U.qerror('验证不通过');
                return false; 
            }else{
                
                // 关闭弹框
                that.closeMd();
                let list = that.fm.ps;
                // 调用父组件方法-传递数据
                that.$emit('reloadDg',list);
                // that.fm.sb.load = true;                             // 添加按钮禁用效果
                // let loading = this.U.qloading('提交中，请稍后...');   // 添加遮罩

                // that.fm.sb.load = false;        // 取消按钮禁用效果
                // that.U.qclose(loading);         // 关闭遮罩

                
            }
        });
    },




    // 查询火车车次
    findTrain(){
        const that = this;

        that.$refs[that.fmTrain.fname].validate((valid) => {
            if(!valid){
                that.U.qerror('验证不通过');
                return false; 
            }else{
                that.fmTrain.sb.load = true;                             // 添加按钮禁用效果
                let loading = this.U.qloading('提交中，请稍后...');   // 添加遮罩

                let info = {
                    date:that.fmTrain.ps.stime,
                    num:that.fmTrain.ps.trainNo,
                    travelWay: 2
                }
                commonService.getStationInfo(info).then(res=> {
                    if(res.code == 1){
                        that.fmTrain.trainResult = [];
                        that.fmTrain.trainResult.push(res.data);
                        // 查询的结果
                        let trainResultList =  that.fmTrain.trainResult;
                        // 当前车次的站点
                        let newStationList = that.newStationList;
                        let strainTwo = [];

                        
                        for(let j=1;j<trainResultList[0].list.length;j++){
                        for(let k=0;k<newStationList.length;k++){
                            if(newStationList[k].nameNote.split(',').indexOf(trainResultList[0].list[j].station) != -1){
                                // $scope.goTimeC = timeAddThirty($scope.trainTime+" "+$scope.trainResult[0].list[j].arrivaltime);
                                // $scope.goTimeC = $scope.trainTime+" "+$scope.trainResult[0].list[j].arrivaltime;


                                // 跨天
                                let trainTimeZh = that.fmTrain.ps.stime+" "+trainResultList[0].list[j].arrivaltime;
                                trainTimeZh = trainTimeZh.replace(new RegExp("-","gm"),"/");
                                let trainTimeHm = (new Date(trainTimeZh)).getTime(); //得到毫秒数
                                let nowHm = 24 * 60 * 60 * 1000;
                                let day = trainResultList[0].list[j].day;

                                let oldTime = (Number(day) - 1) * Number(nowHm) + Number(trainTimeHm);
                                let thisDate = new Date(oldTime);
                                // 年、月、日用字符串“-”拼接
                                that.fmTrain.lookTrainText.stationWrite = trainResultList[0].list[j].station;
                                that.fmTrain.lookTrainText.daTime = trainResultList[0].list[j].arrivaltime;
                                that.fmTrain.lookTrainText.dateJ = that.fmTrain.ps.stime;


                                that.fmTrain.ps.stime= thisDate.getFullYear()+"-"+(thisDate.getMonth()+1)+"-"+thisDate.getDate()+" "+thisDate.getHours()+":"+thisDate.getMinutes();
                                strainTwo.push(newStationList[k]);
                            };
                        };
                        };

                        if(strainTwo.length === 1){ 
                            const that = this;
                            let info = {
                                addressDetail:strainTwo[0].name,
                                LatLng:strainTwo[0].mapPoint.lngLat,
                                areaAll:strainTwo[0].county,
                            }
                            that.fmTrain.ps.address = info;
                            that.fmTrain.ps.startDetail = strainTwo[0].name;
                            // 定义获取查询出来的火车班次号
                            that.fmTrain.ps.trainNumLook = that.fmTrain.trainResult[0].trainno;
                            that.fmTrain.ps.pdisBtn = true;
                        }else if(strainTwo.length === 0){
                            that.U.qerror("查询的火车班次停靠点不在当前城市");
                            that.fmTrain.trainResult = [];
                            that.fmTrain.trainResult.push(res.data);
                            that.fmTrain.lookTrainText.daTime = "";
                            that.fmTrain.ps.pdisBtn = false;
                            that.fmTrain.lookTrainText.stationWrite = "查询的火车班次停靠点不在当前城市";
                        }
                    }else{
                        that.U.qerror(res.msg);
                    }
                })

                that.fmTrain.sb.load = false;        // 取消按钮禁用效果
                that.U.qclose(loading);         // 关闭遮罩
                // 关闭弹框
                // that.closeMd();
            }
        })
    },



    // 航班号查询
    findFlight(){
        const that = this;

        that.$refs[that.fmFlight.fname].validate((valid) => {
            if(!valid){
                that.U.qerror('验证不通过');
                return false; 
            }else{
                 that.fmFlight.sb.load = true;                             // 添加按钮禁用效果
                let loading = this.U.qloading('提交中，请稍后...');   // 添加遮罩

                let info = {
                    date:that.fmFlight.ps.stime,
                    num:that.fmFlight.ps.flightNo,
                    travelWay: 1
                }
                commonService.getStationInfo(info).then(res=> {
                    if(res.code == 1){
                        that.fmFlight.flightResult = res.data.list;
                        let flightResultList = res.data.list;
                        for(let j=0;j<flightResultList.length;j++){
                            for(let k=0;k<that.newStationList.length;k++){
                                if(that.newStationList[k].nameNote.split(',').indexOf(flightResultList[j].arrPort+""+flightResultList[j].arrTerminal) != -1){ 
                                    let info = {
                                        addressDetail:that.newStationList[k].name,
                                        LatLng:that.newStationList[k].mapPoint.lngLat,
                                        areaAll:that.newStationList[k].county,
                                    }

                                    that.fmFlight.ps.address = info;
                                    that.fmFlight.ps.startDetail = that.newStationList[k].name;
                                    // 定义获取查询出来的航班号
                                    that.fmFlight.ps.flightNumLook = that.fmFlight.trainResult[0].trainno;
                                    that.fmFlight.ps.pdisBtn = true;
                                    return false;
                                }else{
                                    // $.misMsg("查询的航班降落点不在当前城市");
                                    that.fmFlight.ps.pdisBtn = false;
                                }
                            }
                        }
                    }else{
                        that.U.qerror(res.msg);
                    }
                });
                that.fmFlight.sb.load = false;        // 取消按钮禁用效果
                that.U.qclose(loading);         // 关闭遮罩
            }
        });
    },

     // 查询飞机航班出现多条时只能选择一条航班-----起点
    activeIndex (index,obj){
        const that = this;

        that.fmFlight.ps.activeSelectFlight = index;
        that.fmFlight.ps.flightResultSelect = obj;
    },



    // 选火车站点无车次号
    checkStation(index,obj){   
        const that = this;
        let info = {
            addressDetail:obj.name,
            LatLng:obj.mapPoint.lngLat,
            areaAll:obj.county,
        }
        that.fmTrain.ps.address = info;
        that.fmTrain.ps.startDetail = obj.name;

        that.fmTrain.ps.activeSelectTrain = index;
        that.fmTrain.ps.backStartAddressSec = (obj.id).toString();
    },
    // 火车车次录入
    trainBtn(){
        const that = this;

        that.$refs[that.fmTrain.fname].validate((valid) => {
            if (!valid) {
                that.U.qerror('验证不通过');
                return false; 
            }else{
                if(that.fmTrain.xs.isTrain == true){
                    if(that.fmTrain.trainResult.length === 0){
                        that.U.qerror('请查询火车车次号');
                    }else if(that.fmTrain.ps.pdisBtn == false){
                         that.U.qerror("查询的火车班次停靠点不在当前城市");
                    }else{
                        // 关闭弹框
                        that.closeMd();
                        let list = that.fmTrain.ps;
                        // 调用父组件方法-传递数据
                        that.$emit('reloadDg',list);
                    }
                }else{
                    if(!that.fmTrain.ps.backStartAddressSec){
                        that.U.qerror('请选择站点');
                    }else{
                        // 关闭弹框
                        that.closeMd();
                        let list = that.fmTrain.ps;
                        // 调用父组件方法-传递数据
                        that.$emit('reloadDg',list);
                    }
                }
            }
        });

    },



    // 选航班站点无车次号
    checkStationFlight(index,obj){   
        const that = this;
        let info = {
            addressDetail:obj.name,
            LatLng:obj.mapPoint.lngLat,
            areaAll:obj.county,
        }
        that.fmFlight.ps.address = info;
        that.fmFlight.ps.startDetail = obj.name;

        that.fmFlight.ps.activeSelectFlight = index;
        that.fmFlight.ps.backStartAddressSec = (obj.id).toString();
    },


    // 航班录入
    saveFlightData(){
        const that = this;

        that.$refs[that.fmFlight.fname].validate((valid) => {
            if (!valid) {
                that.U.qerror('验证不通过');
                return false; 
            }else{
                if(that.fmFlight.xs.isFlight == true){
                    if(that.fmFlight.flightResult.length == 0){
                        that.U.qerror('请查询航班');
                    }else if(that.fmFlight.ps.pdisBtn == false){
                         that.U.qerror("查询的航班降落点不在当前城市");
                    }else{
                        if(that.fmFlight.flightResult.length > 1){
                            if(that.fmFlight.ps.flightResultSelect){
                                that.fmFlight.ps.stime = that.fmFlight.ps.flightResultSelect.arrScheduled;
                                // 关闭弹框
                                that.closeMd();
                                let list = that.fmFlight.ps;
                                // 调用父组件方法-传递数据
                                that.$emit('reloadDg',list);
                            }else{
                                that.U.qerror("请选择航班");
                            }
                        }else if(that.fmFlight.flightResult.length === 1){
                            that.fmFlight.ps.stime = that.fmFlight.flightResult[0].arrScheduled;
                            // 关闭弹框
                            that.closeMd();
                            let list = that.fmFlight.ps;
                            // 调用父组件方法-传递数据
                            that.$emit('reloadDg',list);
                            
                        }
                        
                    }
                }else{
                    if(!that.fmFlight.ps.backStartAddressSec){
                        that.U.qerror('请选择站点');
                    }else{
                        // 关闭弹框
                        that.closeMd();
                        let list = that.fmFlight.ps;
                        // 调用父组件方法-传递数据
                        that.$emit('reloadDg',list);
                    }
                }
            }
        })
    }


  },
 }
</script>
<style lang="less" scoped>
    .flTrain-list{
        width: 30% !important;
        .headerTab{
            margin-bottom: 10px;
            ul{
                display: flex;
                padding-left: 10px;
                margin: 0px;
                li{
                    width: auto;
                    height: 50px;
                    line-height: 50px;
                    text-align: center;
                    cursor: pointer;
                    list-style: none;
                    margin-right: 10px;
                }
            }
            .seatClassClick{
                border-bottom: 2px solid #F76800;
                color: #F76800;
            }
            .content-input{
                display: flex;
            }
        }
        .findTitle{
            margin-left: 10px;
            color: #F76800;
            margin-bottom: 5px;
        }
        .trainFind{
            width: 450px;
            height: 305px;
            resize: none;
            font-size: 16px;
            line-height: 20px;
            border-width: 1px;
            border-style: dashed;
            border-color: rgb(204, 204, 204);
            border-image: initial;
            outline: 0px;
            border-radius: 5px;
            margin: 0 auto;
        }


        .flight-textarea-box{
            width: 90%;
            margin: 0 auto;
            height: 350px;
        .flight-textarea{
            width: 100%;
            height: 200px;
            resize: none;
            border: 1px dashed #ccc;
            outline: none;
            padding-left: 10px;
            padding-right: 10px;
            font-size: 14px;
            line-height: 20px;
            // background: none;
            border-radius: 5px;
            ul{
                margin: 0px;
                padding: 0px;
                li{
                    list-style: none;
                    border-bottom: 1px dashed #ccc;
                    padding-top: 5px;
                    cursor: pointer;
                    p{
                        margin: 0px;
                    }
                }
            }
        }
        .train-textarea{
            width: 100%;
            height: 345px;
            resize: none;
            border: 1px dashed #ccc;
            outline: none;
            // padding-left: 10px;
            // padding-right: 10px;
            font-size: 16px;
            line-height: 20px;
            // background: none;
            border-radius: 5px;
            .train-textarea-header{
                width: 100%;
                height: 36px;
                background: #FFF4E9;
                border-radius: 20px 20px 2px 2px;
                display: flex;
                align-items: center;
                justify-content: space-between;
                font-size: 14px;
                font-family: Microsoft YaHei;
                font-weight: 400;
                color: #000000;

            }
            .train-zd{
                text-align: center;
                width: 100%;
                margin-top: 15px;
            }
            .find-train-list{
                text-align: center;
                margin-top: 15px;
                margin-bottom: 5px;
                .span{
                    display: inline-table;
                }
                .train-btn{
                    // display: block;
                    width: 70px;
                    height: 16px;
                    border: 1px solid #F76800;
                    border-radius: 2px;             
                    font-size: 12px;
                    font-family: Microsoft YaHei;
                    font-weight: 400;
                    color: #F86800;
                    cursor: pointer;
                }
            }
            .train-list{
                width: 400px;
                height: 208px;
                background: #FAFAFA;
                border-radius: 0px 0px 2px 2px;
                margin: 0 auto;
                overflow: auto;
                li{
                    display: flex;
                    p{
                        width: 80px;
                    }
                }
            }
        }
        .flightClassClick{
            background-color:#F76800;
            color: white;
        }
    }

    .flightClass{
        background:#F76800;
    }
    .noTrainzd{
        height: 305px;
        .flightClassClick{
            background-color:#F76800;
        }
    }
    .noTrainzd>ul>li{
        list-style: none;
        width: 100%;
        height: 45px;
        line-height: 45px;
        border-top: 1px solid rgb(204, 204, 204);
        cursor: pointer;
    }
    .noTrainzd>ul>li:last-child{
        border-bottom: 1px solid rgb(204, 204, 204);
        cursor: pointer;
    }
    .marker-icon{
        color: #F76800 !important;
        font-size: 20px !important;
        margin-right: 10px;
    }
    .flTr-btn{
        margin-top: 10px;
    }
    .container {
        width:100%;
        height: 500px;
        position: relative;
        border: 1px solid #999;
    }


    .search-box {
        position: absolute;
        z-index: 5;
        width: 70%;
        left: 13%;
        top: 10px;
        height: 30px;

    input {
        float: left;
        width: 59%;
        height: 100%;
        font-size:13px;
        border: 2px solid #30ccc1;
        padding: 0 8px;
        outline: none;
    }

    button {
        float: left;
        margin-left:5px;
        /* width: 20%;
        height: 100%;
        background: #30ccc1;
        border: 1px solid #30ccc1;
        color: #fff;
        outline: none; */
    }
    }

    .tip-box {
        width: 100%;
        max-height: 260px;
        position: absolute;
        top: 30px;
        overflow-y: auto;
        background-color: #fff;
        z-index: 999;
        margin-top: 5px;
    }

    
        
    }
</style>